package com.example.hbasespringbootdemo.controller;

import com.example.hbasespringbootdemo.constract.TableConstract;
import com.example.hbasespringbootdemo.utils.HbaseUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HbaseController {

    private Logger LOG = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private HbaseUtils hbaseUtils;

    @RequestMapping("insertBranch")
    public boolean insertBranch() {
        try {
            hbaseUtils.insertBranch(TableConstract.TABLE_NAME,
                    new String[] {"row002, row003, row004"},
                    new String[] {"info"}, new String[] {"id", "name", "age"},
                    new String[] {"2", "lisi", "22"});
            return true;
        } catch (Exception e) {
            LOG.error("insert branch fail : ", e);
            return false;
        }
    }
}
